package cn.com.infostrategy.bs.mdata;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestWordServlet extends HttpServlet {

	@Override
	public void service(HttpServletRequest _request, HttpServletResponse _response) throws ServletException, IOException {
		_response.setContentType("application/msword");
//		_response.setHeader("Content-Disposition", "attachment; filename=zzz.doc");
		java.io.OutputStream outStream = _response.getOutputStream();
		java.io.InputStream inStream = new java.io.FileInputStream("C:/zzz.doc");
		byte[] buf = new byte[10240];
		int bytes = 0;
		while ((bytes = inStream.read(buf)) != -1) {
			outStream.write(buf, 0, bytes);
		}
		inStream.close();
		outStream.close();
		_response.flushBuffer(); //
	}
}
